package com.rent.view;

import java.util.Scanner;

import com.rent.bean.User;
import com.rent.dao.UserDao;
import com.rent.Impl.UserDaoImpl;
import com.rent.utils.ViewUtils;
/**
 * 管理员菜单
 * @author xin
 *
 */
public class AdminMenu {
	Scanner input=new Scanner(System.in);
	ViewUtils v = new ViewUtils();
	Option o = new Option();
	AdminOption adminOption = new AdminOption();
	Scanner sn = new Scanner(System.in);
	UserDao user=new UserDaoImpl();
	User uu=new User();
	/**
	 * 管理员用户界面
	 */
	public void menu_admin(User u) {
		l:do {
			System.out.println("***********神州租车系统***********当前用户:" + u.getUname() + "----用户级别：管理员");
			/*
			 * 2、修改用户权限 3、管理车辆 4、管理记录查询 5、会员记录查询 6、租车记录查询
			 * 
			 */
			System.out.println("请选择业务：1、车辆信息  2、用户信息 3.租赁信息 4.退押金 5.损坏车辆 6.会员 7.到期会员 8.统计 9.汽车品牌 10.汽车类型 11.修改密码  0.退出");
			switch (sn.nextInt()) {
			case 0:
				System.out.println("系统退出");
				break l;
			case 1:
				adminOption.showCar();
				continue;
			case 2:
				adminOption.showUser();
				continue;
			case 3:
				adminOption.showRent();
				continue;
			case 4:
				adminOption.returnDeposit();
				continue;
			case 5:
				adminOption.showCarDamage();
				continue;
			case 8:
				adminOption.statistics();
				continue;
			case 6:
				adminOption.showVip();
				continue;
			case 7:
				adminOption.showVipExpire();
				continue;
			case 9:
				adminOption.showBrand();
				continue;
			case 10:
				adminOption.showType();
				continue;
			case 11:
				gaimi();
				continue;
			default:
				System.out.println("输入不合法");
				continue;
			}
		} while (true);
	}
	public void gaimi() {
		System.out.println("请输入用户名:");
//		uu.setUname(input.next());
		String yong=input.next();
		System.out.println("请输入原密码:");
		String pwd=input.next();
//		uu.setUpassword(input.next());
		User us=user.sele_nameAndpwd(yong, pwd);
		if(us!=null) {
			uu.setUname(yong);
			System.out.println("请输入新的密码:");
			uu.setUpassword(input.next());
			int u=user.update(uu);
			if(u!=0) {
				System.out.println("修改成功");
			}
		}
	}
}
